<%@page import="com.lyf.util.DateUtil"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="include/base.jsp" %>

<!DOCTYPE html>
<!-- saved from url=(0038)http://192.168.0.77/pms/idea_show.html -->
<html lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta charset="UTF-8">
	<title>凯盛项目管理系统</title>
	<link href="${basePath }/css/bootstrap.min.css" type="text/css" rel="stylesheet"/>
	<script src="${basePath }/js/jquery-1.8.2.min.js" type="text/javascript"></script>
	<script src="${basePath }/js/bootstrap.min.js" type="text/javascript"></script>
</head>
<body class="body">
	
	<jsp:include page="include/top.jsp"/>
	
	
	<div class="container">
	  <div class="row">
		
		<jsp:include page="include/side.jsp">
			<jsp:param value="linkman" name="tag"/>
		</jsp:include>
		
		<div class="span9">
			<ul class="breadcrumb" style="margin-bottom:0px;border-radius: 3px 3px 0 0;margin-top:15px">
				<li class="active">
					<a href="${basePath }/linkman/toShowLinkman?id=${sessionScope.linkman.id}"><i class="icon-fire"></i>联系人&lt;${sessionScope.linkman.l_name }&gt;:</a>
				</li>
				
			</ul>
			<div class="wall">
				  
				  <form onsubmit="return false;">
					<textarea name="" id="record-des" class="span8" rows="5"></textarea>
					<br>
					<input type="button" class="btn" id="btn" value="发布"/>
					<input type="hidden" value="" id="edit_id"/>
				  </form>
				 
				 <blockquote id="record"></blockquote>
				 <c:forEach items="${recordList }" var="r">
					 <blockquote>
					 	<div id="${r.id }show">
						  ${r.r_describle }
					   	</div>
					   <div style="display:none;" id="${r.id }edit" class="well">
					   		<textarea name="" id="record-des-edit" class="span4" rows="2">${r.r_describle }</textarea><br>
					   		<a href="javascript:;" onclick="editRecord(this)" id="${r.id }"><input type="button" class="btn btn-primary" value="修改" style="margin-left:195px;"/></a>
					   		<a href="javascript:;" onclick="cancleEditRecord(this)" id="${r.id }"><input type="button" class="btn" value="取消" style="margin-left:5px;"/></a>
					   </div>
						  <small>
						  	<c:set var="time" value="${r.r_createTime }" scope="page"></c:set>
						  	<%
						  		String time = (String)pageContext.getAttribute("time");
						  		time = DateUtil.getAskedTime(time);
						  		pageContext.setAttribute("time",time);
						  	%>
							${r.employee.username }发布于 ${time }
							<a href="javascript:;" title="编辑" onclick="edit(this)" id="${r.id }"><i class="icon-pencil"></i></a>
						    <a href="javascript:;" title="删除" onclick="del(this)" id="${r.id }"><i class="icon-trash"></i></a>
						  </small>
					</blockquote>
				</c:forEach>
				
				<a href="${basePath }/linkman/toShowLinkman?id=${sessionScope.linkman.id}">←返回联系人列表</a>
			</div>
		</div>
	  </div>
	</div>
	 <script type="text/javascript">
	  	$("#btn").click(function(){
	  		if($("#record-des").val().trim() != ""){
		  		$.post("${basePath }/record/addRecord",{"desc":$("#record-des").val().trim()},function(obj){
		  			$("#record-des").val(" ");
		  			var blockquote = "<blockquote>" + obj.r_describle +
										  "<small>" +
											obj.employee.username + "发布 于" + obj.r_createTime + 
											"&nbsp;<a href='javascript:;' title='编辑' onclick='edit(this)' id='" + obj.id + "'><i class='icon-pencil'></i></a>&nbsp;" +
										    "<a href='javascript:;' title='删除' onclick='del(this)' id='" + obj.id + "'><i class='icon-trash'></i></a>&nbsp;" +
										  "</small>" +
		  				             "</blockquote>";
		  			$("#record").after(blockquote);
		  		});
	  		}else{
	  			alert("评论内容不能为空");
	  		}
	  	});
	  	function del(obj){
	  		var id = $(obj).attr("id");
	  		$.post("${basePath }/record/delRecord",{"id":id},function(){
	  			$(obj).parent().parent().remove();
	  		});
	  	}
	  	function edit(obj){
	  		var id = $(obj).attr("id");
	  		$("#"+id+"show").hide();
	  		$("#"+id+"edit").show();
	  	}
	  	function cancleEditRecord(obj){
	  		var id = $(obj).attr("id");
	  		$("#"+id+"show").show();
	  		$("#"+id+"edit").hide();
	  	}
	  	function editRecord(obj){
	  		var id = $(obj).attr("id");
	  		if($("#record-des-edit").val().trim() != ""){
		  		$.post("${basePath}/record/editRecord",{"desc":$("#record-des-edit").val().trim(),"id":id},function(desc){
		  			$("#"+id+"show").show();
			  		$("#"+id+"edit").hide();
			  		$("#"+id+"show").text(desc);
		  		});
	  		}
	  	}
	  	
	  </script>

</body></html>
